//----------------------------------
//-----------------Scissors SWEP----
//-----Made by Brian Nevec----------
//----------------------------------
//---Part of the SMOD Weapons Pack--
//----------------------------------

//if on server
if SERVER then

	//send file
	AddCSLuaFile("shared.lua");

	//hold type
	SWEP.HoldType			= "melee";

end

//else if on client
if CLIENT then

	//info
	SWEP.PrintName			= "Scissors";
	SWEP.Author				= "Brian Nevec";
	SWEP.Slot				= 2;
	SWEP.SlotPos			= 3;
	SWEP.Purpose			= "Cuts you up";
	SWEP.Instructions		= "Left Click: Fire, Right Click: Spread fire";

	//category
	SWEP.Category			= "SMOD";
	
	//selection icon
	SWEP.WepSelectIcon = surface.GetTextureID("weapons/scissoricon");

	-- Kill Icon
	if(file.Exists("../materials/weapons/scissor_killicon.vmt")) then

		killicon.Add("smod_scissor","weapons/scissor_killicon",Color(255,255,255));

	end 
end

//is it spawnable?
SWEP.Spawnable				= true;
SWEP.AdminSpawnable			= false;

//models
SWEP.ViewModel				= "models/weapons/v_hasami.mdl";
SWEP.WorldModel				= "models/weapons/w_hasami.mdl";

//more info
SWEP.Weight					= 25;
SWEP.AutoSwitchTo			= false;
SWEP.AutoSwitchFrom			= false;

//primary
SWEP.Primary =
{
	ClipSize				= 1,
	DefaultClip				= 100,
	Automatic				= true,
	Ammo					= "XBowBolt"
}

//secondary
SWEP.Secondary =
{
	ClipSize				= -1,
	DefaultClip				= -1,
	Automatic				= true,
	Ammo					= "none"
}

//sounds
SWEP.Sounds =
{
	Shoot = Sound("weapons/scissor/fire.wav")
}

//on init
function SWEP:Initialize()

	//if on server
	if SERVER then

		//set hold type
		self:SetWeaponHoldType(self.HoldType);

	end

end

//primary attack
function SWEP:PrimaryAttack()

	//if we can fire
	if self.Weapon:CanPrimaryAttack() then

		//if on server
		if SERVER then

			//pos and ang
			local Pos = self.Owner:GetShootPos();
			local Ang = self.Owner:GetAngles();

			//entity
			local Scissor = ents.Create("smod_scissor");

			//if valid
			if ValidEntity(Scissor) then

				//set up
				Scissor:SetPos(Pos);
				Scissor:SetAngles(Ang);
				Scissor:Spawn();
				Scissor:Activate();
				Scissor:SetOwner(self.Owner);

			end

		end

		//animations
		self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK);
		self.Owner:SetAnimation(PLAYER_ATTACK1);

		//sound
		self.Owner:EmitSound(self.Sounds.Shoot);

		//take ammo
		self.Weapon:TakePrimaryAmmo(1);

		//RELOAD
		timer.Simple(0.3,self.Weapon.DefaultReload,self.Weapon,ACT_VM_RELOAD);

	end

	//delay
	self.Weapon:SetNextSecondaryFire(CurTime() + 0.75);
	self.Weapon:SetNextPrimaryFire(CurTime() + 0.75);

	//return false
	return false;

end

//secondary
function SWEP:SecondaryAttack()

	//if we can fire
	if self.Weapon:CanPrimaryAttack() then

		//if on server
		if SERVER then

			//pos
			local Pos = self.Owner:GetShootPos();

			//3 shots
			for I = 0,2 do

				//angle
				local Ang = self.Owner:GetAngles();

				//rotate it accordingly
				Ang:RotateAroundAxis(Ang:Up(),(I - 1) * 20);

				//create entity
				local Scissor = ents.Create("smod_scissor");

				//if valid
				if ValidEntity(Scissor) then

					//set up
					Scissor:SetPos(Pos);
					Scissor:SetAngles(Ang);
					Scissor:SetOwner(self.Owner);
					Scissor:Spawn();
					Scissor:Activate();

				end

			end

		end

		//animations
		self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK);
		self.Owner:SetAnimation(PLAYER_ATTACK1);

		//sound
		self.Owner:EmitSound(self.Sounds.Shoot);

		//take 3 ammo
		self.Weapon:TakePrimaryAmmo(3);

		//RELOAD
		timer.Simple(0.3,self.Weapon.DefaultReload,self.Weapon,ACT_VM_RELOAD);

	end

	//delay
	self.Weapon:SetNextSecondaryFire(CurTime() + 0.75);
	self.Weapon:SetNextPrimaryFire(CurTime() + 0.75);

	//return
	return false;

end

//when we deploy
function SWEP:Deploy()

	//run the deploy animation
	self.Weapon:SendWeaponAnim(ACT_VM_DRAW);

	//and return
	return true;

end